<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
  <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
  <title>学术</title>
  <style>
		html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
		.h20 {height: 0.5rem;background: #f0f0f0;}

        #header_top {
            background: #2997e4;
            padding-top: 25px;
        }
    .xsContent {
      /*margin-top: 12px;*/
    }
    .xsContent .aui-list-item-media {
      width: 6.5rem;
    }
    .xsContent .aui-list-item .aui-list-item-title {
      color: #333;
      line-height: 1.2rem;
      font-size: 0.8rem;
    }
    .xsContent .aui-list-item .aui-info-item {
      color: #999;
      font-size: 0.7rem;
    }
    .xsContent .aui-media-list .aui-list-item-inner {
      display: -webkit-box;
      display: -webkit-flex;
      display: flex;
      -webkit-box-orient: vertical;
      box-orient: vertical;
      -webkit-flex-direction: column;
      flex-direction: column;
      -webkit-box-pack: justify;
      -webkit-justify-content: space-between;
      justify-content: space-between;
      -webkit-box-align: start;
      -webkit-align-items: flex-start;
      align-items: flex-start;
    }
    .itemIco {
      width: 100%;
      height: 4rem;
    }
    #header_top {
      position: fixed;
      width: 100%;
      top:0;
      z-index: 99;
    }
    .xsContent {
      min-height: calc(100vh - 65px);
    }
    body {
      padding-top: 65px;
    }
	</style>
</head>
<body>
  <header id="header_top" class="aui-bar aui-bar-nav" >

    <a class="aui-pull-left"  onclick="goback()">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title" id="title">
    政策
  </div>
      <a class="aui-pull-right" id="search_6" onclick="openSearch('article', 4)">
          <span class="aui-iconfont aui-icon-search"></span>
      </a>
  </header>
  <section class="aui-refresh-content">
<div class="aui-content xsContent" id="app" v-cloak>
  <ul class="aui-list aui-media-list">
    <li class="aui-list-item" @click="openDetail('xc', '文章详情', item.newsId)" v-for="item in newsList">
      <div class="aui-media-list-item-inner">
        <div class="aui-list-item-media">
          <!-- <img :src="item.pics" alt="" v-if="item.pics && item.pics != ''">
          <img src="../../image/banner1.jpg" alt="" v-else> -->
          <div v-if="item.pics && item.pics != ''" class="itemIco" :style="'background: url('+ item.pics +') center/cover no-repeat'"></div>
          <div v-else class="itemIco" style="background: url(../../image/banner1.png) center/cover no-repeat"></div>
        </div>
        <div class="aui-list-item-inner">
          <div class="aui-list-item-text">
            <div class="aui-list-item-title">{{item.title}}</div>
          </div>
          <div class="aui-info aui-margin-t-5" style="padding:0">
            <div class="aui-info-item">{{item.createTime}}</div>
          </div>
        </div>
      </div>
    </li>
  </ul>
</div>
</section>
<script src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script>
    function goback () {
      api.closeWin({name:api.pageParam.name});
    }
apiready = function() {

  var app = new Vue({
    el: '#app',
    data: {
		    page: 1,
        totalpage: 1,
        newsList: []
    },
    created: function() {
      var $_this = this;
      api.ajax({
        url: window.Url.getArticleList + '4/' + $_this.page,
      timeout: 300,
    }, function(ret, err) {
        if (ret) {
          if (ret.code == 1) {
            return
          }
            $_this.totalpage = ret.data.totalpage
            $_this.newsList = ret.data.newsList
        } else {
            api.alert({ msg: JSON.stringify(err) });
        }
    })


var scroll = new auiScroll({
        listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
        distance:40 //判断到达底部的距离，isToBottom为true
    },function(ret){
       if (ret.isToBottom) {
         $_this.page ++
         if ($_this.page > $_this.totalpage) {
           $_this.page = $_this.totalpage
           return
         }
         api.ajax({
           url: window.Url.getArticleList + '4/' + $_this.page,
          timeout: 300,
        }, function(ret, err) {
            if (ret) {
               //  api.alert({ msg: JSON.stringify(ret) });
                $_this.newsList = $_this.newsList.concat(ret.data.newsList)

            } else {
                api.alert({ msg: JSON.stringify(err) });
            }
        })
       }

    });

    var pullRefresh = new auiPullToRefresh({
        container: document.querySelector('.aui-refresh-content'),
        triggerDistance: 100
    },function(ret){
        if(ret.status=="success"){
          $_this.page = 1
          api.ajax({
            url: window.Url.getArticleList + '4/' + $_this.page,
          timeout: 300,
        }, function(ret, err) {
            if (ret) {
              setTimeout(function() {
                if (ret.code == 1) {
                  pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                  return
                }
                  $_this.totalpage = ret.data.totalpage
                  $_this.newsList = ret.data.newsList
                  pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
              },500)

            } else {
                api.alert({ msg: JSON.stringify(err) });
            }
        })

        }
    })

    },
    methods: {
      openDetail: function (type, title, id) {
        api.openWin({
          name: 'index_detail_' + type,
          pageParam: {
            name: 'index_detail_' + type,
            title: title,
            id: id,
            detail_type: 'zc'
          },
          url: './index_detail_' + type + '.html',
          delay: 200,
          bounces: false
        });
      }
    }
  })
}
function openSearch(type, cid) {
  api.openWin({
  name: 'search',
  url: '../search.html',
  bounces: false,
  pageParam: {
    type: type,
    cid: cid
  },
  delay:200
  });
}
</script>
</body>
</html>
